<template>
  <div class="searchList" v-if="playlist.hasMore">
    <div class="playlisttop">
      <div class="left">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-bofang" />
        </svg>
        <div class="tetle">
          播放全部
          <span>(共{{ playlist.songs.length }}首)</span>
        </div>
      </div>
      <div class="rigth">
        <van-button type="danger" class="danger">收藏({{ playlist.songCount }})</van-button>
      </div>
    </div>
    <div class="musiclist">
      <div class="list" v-for="(item, index) in playlist.songs" :key="item.id" @click="play(item,index)">
        <div class="num" v-text="index + 1"></div>
        <div class="music">
          <div class="name" v-text="item.name"></div>
          <div class="antor">
            <span v-for="(item ) in item.artists" :key="item.id">{{ item.name }} &nbsp;</span>
            <span>-{{ item.name }}</span>
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-bofang" />
            </svg>
          </div>
        </div>
        <div class="icon">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-liebiao2" />
          </svg>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    playlist: {
      type: Object,
      default: {}
    }
  },
  methods: {
    play(item,index) {
      console.log(index)
      // this.$emit('playdata',al)
      item.al = item.album
      item.al.picUrl = item.album.artist.img1v1Url
      this.$store.commit('pushplayList',item)
      this.$store.commit('setpalyIndex', this.$store.state.playList.length-1)
    }
  }
}
</script>

<style lang="less" scoped>
.searchList {
  position: absolute;
  background-color: #fff;
  width: 100%;
  height: 80%;
  border-radius: 0.2rem 0.2rem 0 0;
  // top: 6rem;
  overflow: auto;
  .playlisttop {
    display: flex;
    justify-content: space-between;
    border-bottom: 0.01rem solid #ccc;
    .left {
      flex: 1;
      display: flex;
      .icon {
        width: 0.4rem;
        height: 0.4rem;
        margin: 0.3rem 0.15rem;
      }
      .tetle {
        // height: 0.8rem;
        font-weight: 700;
        font-size: 0.4rem;
        height: 1rem;
        line-height: 1rem;

        span {
          display: inline-block;
          // height: 0.8rem;
          font-weight: 400;
          font-size: 0.3rem;
          color: #ccc;
          margin-bottom: 0.2rem;
          // line-height: 0.5rem;
        }
      }
    }
    .rigth {
      .danger {
        border-radius: 0.2rem;
        // width: 1.5rem;
        padding: 0 0.3rem;
        height: 0.7rem;
        margin: 0.1rem 0.3rem;
      }
    }
  }
  .musiclist {
    .list {
      padding: 0.3rem 0.1rem;
      display: flex;
      justify-content: space-between;
      .music {
        width: 80%;
        .antor {
          color: #ccc;
          font-size: 0.1rem;
          position: relative;
          .icon {
            width: 0.5rem;
            height: 0.5rem;
            position: absolute;
            right: 2%;
            top: -0.4rem;
          }
        }
      }
      .icon {
        .icon {
          width: 0.5rem;
          height: 0.5rem;
          margin-left: -0.2rem;
        }
      }
      .num {
        width: 5%;
        color: #ccc;
      }
      .icon {
        width: 5%;
      }
    }
  }
}
</style>